#include "StdAfx.h"
#include "point_2.h"
#include "box_2.h"


point_2 point_2::interpolate(const point_2& ep, double t) const
{
  return *this + (ep - *this)*t;
}

bool point_2::intersects(const box_2& box) const
{
  return box.within(*this);
}

double point_2::distance(const point_2& pt0, const point_2& pt1, double len) const
{
  if(len != 0) {
    return fabs(((pt0.y-pt1.y)*x+(pt1.x-pt0.x)*y+(pt0.x*pt1.y-pt1.x*pt0.y))/len);
  }

  return distance(pt0);
}

